<?php
namespace app\models\user;

use app\admin\model\BaseModel;
use app\admin\model\ModelTrait;


class LoanCollection extends BaseModel
{
    /**
     * 数据表主键
     * @var string
     */
    protected $pk = 'id';

    use ModelTrait;


    /**
     * 收藏列表
    */
    public static function pageList($where,$uid)
    {
        $model = new self;
        $model = $model->alias("c")->join("loan l","l.id = c.loan_id");
        $model = $model->where("c.uid",$uid);
        $model = $model->page((int)$where['page'],(int)$where['limit']);
        $model = $model->field("l.image,l.name,l.quota,l.url,l.info,c.create_time");
        $model = $model->order("c.create_time desc");
        $data = $model->select()->each(function ($item) {
            $quota = SystemConfigMore(['website_domain']);
            $item['image'] = str_replace("\\","/",$quota['website_domain'] . $item['image']);
            $item['info'] = explode("\r\n",$item['info']);
        });
        return $data ? $data->toArray() : [];
    } 
}
